﻿# define DEBUG_AGENT
using Microsoft.Phone.Scheduler;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace http
{
    class BackAgent
    {
        public void backagent()
        {
            try
            {
                var oldTask = ScheduledActionService.Find("http") as PeriodicTask;
                if (oldTask != null)
                    ScheduledActionService.Remove("http");

                PeriodicTask task = new PeriodicTask("http");

                task.Description = "Periodically Updates Primary Tile for http";

                ScheduledActionService.Add(task);
#if(DEBUG_AGENT)
                ScheduledActionService.LaunchForTest("http", TimeSpan.FromSeconds(6));
#endif

            }
            catch (InvalidOperationException ex)
            {
               
            }
        }
    }
}
